Xbasic

*PATTERN_LOOKUPI Function

Syntax

Result as C = *PATTERN_LOOKUPI(text as c, key as c, pattern as c, otherwise as c)

Arguments

textCharacter

Contains a delimited list to search for a pattern. The delimiter is the last character in the Pattern string.

keyCharacter

The value to find in Text.

patternCharacter

A string with two "*" placeholders in it. The first placeholder encountered is the Key. The second is the Result to return. The Pattern must have one or more characters between the two placeholders, and a list delimiter at the beginning, at the end, or at both the beginning and end of the Pattern string.

otherwiseCharacter

The value to return if the Key is not found in the list.

Returns

ResultCharacter

The value returned by the function. If the Key is not found, the function returns Otherwise.

Description

Looks up a value matching a key on text, if none found return 'otherwise' condition.

Discussion

The *PATTERN_LOOKUPI() function performs a case-insensitive search of a character string for the specified key value.

Example

? *pattern_lookupi("one=1,two=2,three=3","two","*=*,","0")
= "2"

? *pattern_lookupi("one=1,two=2,three=3","four","*=*,","0") 
= "0"

? *pattern_lookupi("one=1,two=2,three=3","three","*=*,","0") 
= "3"

See Also